package com.wisdudu.blank.ui.common;

import android.databinding.BaseObservable;
import android.databinding.ObservableField;

import com.kelin.mvvmlight.command.ReplyCommand;

/**
 * Created by qyf on 2016/9/2.
 * 需要搜索功能的继承此VM，实现具体方法即可，注意include进view_search布局
 */

public abstract class SearchVM extends BaseObservable {
    public final ObservableField<String> searchEtHint = new ObservableField<>();//搜索框hint
    public final ObservableField<String> searchKeyword = new ObservableField<>();//搜索关键字

    //清除搜索关键字
    public ReplyCommand clearSearchKeyword = new ReplyCommand(() -> {
        searchKeyword.set("");
        onClearSearchKeywordClick();
    });

    //点击清除搜索
    protected abstract void onClearSearchKeywordClick();

    public ReplyCommand<String> searchKeywordTextChanged = new ReplyCommand<>(this::afterSearchKeywordTextChanged);

    //搜索框变化
    protected abstract void afterSearchKeywordTextChanged(String searchKeyword);
}
